import { createStore } from 'vuex'
import userModule from './modules/user'
import tagsViewModule from './modules/tagsView'
import messageModule from './modules/message'
import friendModule from './modules/friend'
import userManageModule from './modules/admin/userManage'
import collegeManageModule from './modules/admin/collegeManage'
import lessonManageModule from './modules/admin/lessonManage'
import noticesManageModule from './modules/admin/noticesManage'
import selectCourseModule from './modules/student/selectCourseManage'

const store = createStore({
  state() {
    return {
    }
  },
  mutations: {

  },
  actions: {

  },
  getters: {},
  modules: {
    userModule,
    tagsViewModule,
    messageModule,
    friendModule,
    userManageModule,
    collegeManageModule,
    lessonManageModule,
    noticesManageModule,
    selectCourseModule
  }
})

export function setupStore() {
  // 调用 login 模块里的action方法，防止用户刷新后，仓库的数据丢失
  store.dispatch('userModule/loadLocalLoginAction')
  // store.dispatch('collegeManageModule/getAllCollege')
}

export default store
